<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>计算样式和clientWidth</title>
  <style>
    .width {
        width: 200px;
        height: 200px;
        padding: 20px;
        border: 2px solid black;
        box-sizing: content-box;
    }
  </style>
</head>
<body>
<div class="width">

</div>
<script>
  const dom = document.querySelector('.width');
  console.log(dom.offsetWidth, dom.clientWidth, getComputedStyle(dom).width);
</script>
</body>
</html>